<div class="artCon" id ="seluser">
	<div style="width:650px;padding: 0;height:310px;overflow:hidden;">
		<div id="menuContent" class="menuContent" style="display:none; position: absolute;border: 1px solid #09f;width:213px;overflow:auto;;background-color:#FFFFFF;height:150px;">
			<ul id="treeDemo" class="ztree"></ul>
		</div>
		<form class="form-horizontal" id="mainForm" action="" data-toggle="ajax-form" data-target="#auth" method="post">
        <div class="artMain artOther" style="height:256px;">
			<div class="mainTop" style="background-color:#EFEFEF;">
				<h3>用户目录位置：</h3>
				<div class="input_wrap" id="cubedic">
					<img src="<#if usertype ?? && usertype == 'role'>/assets/images/usergroup.png<#else>/assets/images/userrole.png</#if>" height="16" style="top:0;margin-top:7px;"> <input
						id="dicinput" type="text" value="<#if usertype ?? && usertype == 'role'>角色分组<#else>用户分组</#if>" class="txt_1 txt"
						onclick="showMenu(this)" readOnly="readOnly"
						style="width:160px;border: 1px solid #09f;"> <a
						href="javascript:showMenu(this)" id="cubelist"><i
						class="selectIco"></i> </a>
			
				</div>
				
				<#if usertype =="organ">
				<div>
				  <input style="margin-top: 4px;border: 1px solid #cccccc;height: 14px;padding: 4px;"  size="25"  id="show_username" maxlength="30" name="show_username" value="" type="text">

			      <input type="button" style="padding-top:5px" onclick="submitSearchForm();" class="subButtonStyle" value="查询"> 
				</div>
				</#if>
			</div>
			<div class="leftList" style="height:180px;">
				<ul>
					<a href="javascript:void(0)" onclick="loadURL('/${orgi}/user/report/0/organ/selUser.html?a=b<#if sub??>&sub=true</#if><#if seltype??>&seltype=model<#if cubeid??>&cubeid=${cubeid!''}</#if><#if measureid??>&measureid=${measureid!''}</#if><#if levelid??>&levelid=${levelid!''}</#if></#if>','#seluser',function(){hideMenu();})">
					<li <#if usertype ?? && usertype =="organ">class="cur"</#if>><i class="imgIco-15"></i><a href="#">用户分组</a></li>
					</a>
					<a href="javascript:void(0)" onclick="loadURL('/${orgi}/user/report/0/role/selUser.html?a=b<#if sub??>&sub=true</#if><#if seltype??>&seltype=model<#if cubeid??>&cubeid=${cubeid!''}</#if><#if measureid??>&measureid=${measureid!''}</#if><#if levelid??>&levelid=${levelid!''}</#if></#if>','#seluser',function(){hideMenu();})">
					<li <#if usertype ?? && usertype =="role">class="cur"</#if>><i class="imgIco-15"></i><a href="#">角色分组</a></li>
					</a>
				</ul>
			</div>
			<div class="rightCon" style="width:555px !important;height:210px;overflow-y:scroll;">
				<div class="rightList" id="cubeList" style="overflow:auto;overflow-x:hidden;">				
				<#include "userdic.html"/>
				</div>
			</div>
        </div>
        <div class="bottomBg">
            <div class="btnWrap">
                <a href="javascript:sbt()" class="btnStyle1">选择</a>
            </div>
        </div>
		</form>
    </div>
</div>
<script type="text/javascript">
	var setting = {
		view: {
			dblClickExpand: false
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onClick: onClick
		}
	};
	var zNodes =[
		{ id:'0', pId:0, name:"<#if usertype ?? && usertype == 'role'>角色分组<#else>用户分组</#if>", open:true, icon:"<#if usertype ?? && usertype == 'role'>/assets/images/usergroup.png<#else>/assets/images/userrole.png</#if>",click:"loadURL('/${orgi}/user/report/user/${usertype}/0/userdic.html?a=b<#if sub??>&sub=true</#if><#if seltype??>&seltype=model</#if>','#cubeList',function(){hideMenu();})"}
		<#if userPackageList??>
		<#list userPackageList as userPackage>
		,{ id:"${userPackage.id!''}", pId:"<#if usertype ?? && usertype == 'role'>${userPackage.groupid!''}<#else>${userPackage.parentid!''}</#if>", name:"${userPackage.name!''}", icon:"/assets/images/icon-file-closed.png",click:"loadURL('/${orgi}/user/report/user/${usertype}/${userPackage.id}/userdic.html?a=b<#if sub??>&sub=true</#if><#if seltype??>&seltype=model</#if>','#cubeList',function(){hideMenu();$('#dicinput').val('${userPackage.name!''}');})"}
		</#list>
		</#if>
		//<#if userPackageGroup??>
		//<#list userPackageGroup as group>
		//,{ id:"${group.id!''}", pId:"${group.parentid!''}", name:"${group.name!''}", icon:"/assets/images/icon-file-closed.png",click:"loadURL('/${orgi}/user/report/user/${usertype}/${group.id}/userdic.html','#cubeList',function(){hideMenu();})"}
		//</#list>
		//</#if>
	 ]; 
	 function onClick(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
		nodes = zTree.getSelectedNodes(),
		v = "";
		nodes.sort(function compare(a,b){return a.id-b.id;});
		for (var i=0, l=nodes.length; i<l; i++) {
			v += nodes[i].name + ",";
		}
		if (v.length > 0 ) v = v.substring(0, v.length-1);
		var cityObj = $("#cubedic");
		cityObj.attr("value", v);
	}

	function showMenu() {
		var cityObj = $("#cubedic");
		var cityOffset = $("#cubedic").position();
		$("#menuContent").css({left:cityOffset.left+"px", top:(cityOffset.top+25)+"px"}).show();

		$("body").bind("mousedown", onBodyDown);
	}
	function hideMenu() {
		$("#menuContent").hide();
		$("body").unbind("mousedown", onBodyDown);
	}
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
			hideMenu();
		}
	}
	
	function sbt(){
		<#if seltype??>
		$("#mainForm").attr("action","/${orgi}/dm/cube/${cubeid!''}/authrolesdo.html?<#if measureid??>measureid=${measureid!''}</#if><#if levelid??>levelid=${levelid!''}</#if>");
		$("#mainForm").submit();
		if(currentArtDialog!=null){
			currentArtDialog.close();
		}
		<#else>
		window.parent.selUserGroupclose();
		</#if>
		
	}

	/*$(function(){
		var lefeHeight=$(".leftList").outerHeight(),rightHeight=$(".rightList").outerHeight();
		if(lefeHeight>rightHeight){
			$(".leftList,.rightList").height(lefeHeight);
		}else{
			$(".leftList,.rightList").height(rightHeight);
		}
		
	});*/
	
	 $(document).ready(function(){
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
	});
	function submitSearchForm(){
	  var v_username=$("#show_username").val();
	  loadURL('/${orgi}/user/report/0/organ/selUser.html?username='+v_username<#if seltype??>+'&seltype=model'</#if>,'#seluser');
	}
</script>